package com.redoor.app.stake.basicdata.controller;

import com.redoor.app.stake.basicdata.model.LogEnum;
import com.redoor.app.stake.basicdata.service.BaseStationService;
import com.redoor.app.stake.basicdata.service.LogService;
import com.redoornetwork.framework.core.response.ResponseResult;
import com.redoornetwork.framework.core.response.ResultGenerator;
import com.redoornetwork.framework.data.redis.util.RedisUtils;
import com.yotouch.app.stake.model.Station;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wangjunlei on 2018/2/14.
 */

@RestController
@RequestMapping("/redis")
@Api(value = "Redis功能测试类")
public class RedisController {

    @Autowired
    private RedisUtils redisUtils;

    @Autowired
    private BaseStationService stationService;

    @Autowired
    private LogService hsfLogService;

    @ApiOperation(value = "Reids初始化", notes = "")
    @PostMapping("/constomer/init")
    public ResponseResult init() throws Exception {
        return ResultGenerator.generatorSuccess(stationService.initHSFStationRedis());
    }

    @ApiOperation(value = "Reids根据站uuid获取站信息", notes = "")
    @PostMapping("/constomer/get")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uuid", value = "站id", paramType = "query", dataType = "string", required = true, defaultValue = "")
    })
    public ResponseResult get(String uuid) throws Exception {
        Station list2 = stationService.findByUuidForHsf(uuid);
        return ResultGenerator.generatorSuccess(list2);
    }

    @ApiOperation(value = "从Redis中获取HSF操作日志", notes = "获取一条Redis中删除一条")
    @PostMapping("/HsfOperatorLog/get")
    public ResponseResult getHsfOperatorLog() throws Exception {
        return ResultGenerator.generatorSuccess(hsfLogService.getLogFromRedis(10,LogEnum.HSF_LOG));
    }
}
